﻿using UnityEngine;
using TinyWnd;

public class WRankItemTemp : MonoBehaviour
{
    UISprite sprite;
    UILabel label;

    RankItemData _item;

    void Awake()
    {
        var tran = transform;
        sprite = Utility.FindChild<UISprite>(tran, "Bg/Equip");
        label = Utility.FindChild<UILabel>(tran, "Label");

        UIEventListener.Get(sprite.gameObject).onClick = delegate
        {
            ClickItem();
        };
    }

    public void InitItem(RankItemData item)
    {
        _item = item;
        sprite.spriteName = item.spriteName;
        label.text = item.lblName;
    }

    void ClickItem()
    {
        var w = WndMgr.inst.GetWnd<RankWnd>(WndId.rank);
        if (w != null)
            w.ShowRankDetail(_item);
    }
}
